package lib

import (
	"RMS/app/shop/model"
	"RMS/common"
	"RMS/common/cache"
	"context"
	"log"
	"strconv"
)

func ImplDeleteCart(ctx context.Context, req *model.DeleteCartReq) *model.DeleteCartResp {
	resp := &model.DeleteCartResp{}
	key := cache.GetCartKey(ctx, strconv.FormatInt(int64(req.Id), 10))
	if _, err := cache.RDB.HDel(ctx, key, req.Uuid).Result(); err != nil {
		log.Printf("deleteCart Err := %v\n", err.Error())
		resp.Status = common.ErrCode
		resp.Message = common.DelErrMessage
		return resp
	}
	resp.Status = common.SuccessCode
	resp.Message = common.SuccessMessage
	return resp
}
